# CMake 最低版本号要求
cmake_minimum_required (VERSION 2.8)

# 项目名称
set(PROJECT_NAME HelloServer)

# 项目信息
project (${PROJECT_NAME})

# 查找当前目录下的所有源文件
# 并将名称保存到 DIR_SRCS 变量
aux_source_directory(. DIR_SRCS)

# 设置Mysql相关的依赖路径
set(MYSQL_DIR_INC "/usr/include/mysql")
set(MYSQL_DIR_LIB "/usr/lib64/mysql")


# 设置tars基础服务库的路径
set(TARS_PATH "${PROJECT_SOURCE_DIR}/../plantfrom")
set(TARS_INC "${TARS_PATH}/include")
set(TARS_LIB "${TARS_PATH}/lib")

# 设置编译选项
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -g -Wall -Wno-deprecated")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Wno-deprecated")

# 设置*.tars文件转cpp文件的工具tars2cpp的路径
set(TARS2CPP "${TARS_PATH}/tools/tars2cpp")
# 当前目录下查找所有的tars格式文件
file(GLOB TARS_SRC  ${PROJECT_SOURCE_DIR}/*.tars)

# 执行tars转cpp的程序
execute_process(COMMAND ${TARS2CPP} ${TARS_SRC}
                WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})

# 添加头文件的包含路径
include_directories(${MYSQL_DIR_INC})
include_directories(${TARS_INC})

# 添加库文件的包含路径
link_directories(${MYSQL_DIR_LIB})
link_directories(${TARS_LIB})

# 指定生成目标
add_executable(${PROJECT_NAME} ${DIR_SRCS})
target_link_libraries(${PROJECT_NAME} tarsservant tarsparse tarsutil)
target_link_libraries(${PROJECT_NAME} pthread)
